<h2 class="dialog_title"><span>Punishment Keseluruhan</span></h2>
<div class="dialog_content" style="padding: 10px 20px; width:700px">
<table width="100%" border="0" cellpadding="5" cellspacing="0">
	<tr>
    	<td width="60">Periode : </td>
		<td><strong><?php echo "$month-$year" ?></strong></td>
	</tr>
</table>
<table style="border:1px solid #457A3F;" width="100%" border="0" cellpadding="5" cellspacing="0">
  <tr class="header">
	<th align="left"><span class="colorWhite">Karyawan</span></th>
    <th align="left"><span class="colorWhite">Jenis</span></th>
    <th align="left"><span class="colorWhite">Bidang</span></th>
    <th align="left"><span class="colorWhite">Tingkat</span></th>
    <th align="left"><span class="colorWhite">Kategori</span></th>
  </tr>
  <tbody id="searchKary-table" style="overflow:scroll; max-height:200px; height:200px">
<?php 
	$result = mysql_query(
				"SELECT a.KODE_KARYAWAN, e.NAMA_KARYAWAN, c.ACHIEV_JENIS, c.ACHIEV_BIDANG, 
						d.DETACHIEV_TINGKAT, d.DETACHIEV_NAMA 
				FROM perbuatan AS a, detil_perbuatan AS b, prestasipelanggaran AS c, 
					detil_prestasi_pelanggaran AS d, data_karyawan e 
				WHERE a.KODE_KARYAWAN = e.KODE_KARYAWAN 
					AND a.PERB_NO = b.PERB_NO 
					AND b.DETACHIEV_ID = d.DETACHIEV_ID 
					AND d.ACHIEV_ID = c.ACHIEV_ID 
					AND year(a.PERB_TGL)='$year' AND month(a.PERB_TGL)='$month'");
	$jmlPunishment = 0;
	$jmlRP = 0;
?>
<?php while ( $tt = mysql_fetch_assoc($result) ): ?>
	<?php if (strtolower($tt['ACHIEV_JENIS'])=="pelanggaran"):?>
	<?php $jmlPunishment++ ?>
    <tr <?php echo tag_zebra($ZZ++)?>>
        <td><?php echo $tt['NAMA_KARYAWAN'] ?></td>
        <td><?php echo $tt['ACHIEV_JENIS'] ?></td>
        <td><?php echo $tt['ACHIEV_BIDANG'] ?></td>
        <td><?php echo $tt['DETACHIEV_TINGKAT'] ?></td>
        <td><?php echo $tt['DETACHIEV_NAMA'] ?></td>
    </tr>
    <?php endif ?>
    <?php $jmlRP++ ?>
<?php endwhile; ?>
  </tbody>
  <tr class="header">
	<th align="right" colspan="4"><span class="colorWhite">Jumlah Reward:</span></th>
    <th align="right"><span class="colorWhite"><?php echo $jmlPunishment ?></span></th>
  </tr>
  <tr class="header">
	<th align="right" colspan="4"><span class="colorWhite">Jumlah Reward & Punishment: </span></th>
    <th align="right"><span class="colorWhite"><?php echo $jmlRP ?></span></th>
  </tr>
  <tr class="header">
	<th align="right" colspan="4"><span class="colorWhite">Rata-rata Punishment: </span></th>
    <th align="right"><span class="colorWhite"><?php echo $jmlRP? number_format($jmlPunishment/$jmlRP,2) : 0 ?></span></th>
  </tr>
</table>
</div>
<div class="dialog_buttons"><input type="button" value="Close" name="close" onclick="FBModal_hide()" /></div>